﻿#region Imports
using System.Reflection;
#endregion

namespace BulkRenamer.Util.Info
{
    /// <summary>
    /// Application info
    /// </summary>
    public static class AppInfo
    {
        #region Declarations
        /// <summary>
        /// Constant for author email
        /// </summary>
        private const string authorEmail = "rupakkd@gmail.com";
        #endregion

        #region Properties
        /// <summary>
        /// Assembly of currently executing application
        /// </summary>
        private static Assembly CurrentAssembly
        {
            get { return Assembly.GetEntryAssembly(); }
        }

        /// <summary>
        /// Assembly title
        /// </summary>
        public static string AssemblyTitle
        {
            get
            {
                //object[] attributes = CurrentAssembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
                //if (attributes.Length > 0)
                //{
                //    AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
                //    if (!String.IsNullOrEmpty(titleAttribute.Title))
                //        return titleAttribute.Title;
                //}
                //
                //return Path.GetFileNameWithoutExtension(CurrentAssembly.CodeBase);

                return CurrentAssembly.GetName().Name;
            }
        }

        /// <summary>
        /// Product version
        /// </summary>
        public static string AssemblyVersion
        {
            get { return CurrentAssembly.GetName().Version.ToString(); }
        }

        /// <summary>
        /// Product description
        /// </summary>
        public static string AssemblyDescription
        {
            get
            {
                object[] attributes = CurrentAssembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
                if (attributes.Length == 0)
                    return "";

                return ((AssemblyDescriptionAttribute)attributes[0]).Description;
            }
        }

        /// <summary>
        /// Product name
        /// </summary>
        public static string AssemblyProduct
        {
            get
            {
                object[] attributes = CurrentAssembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false);
                if (attributes.Length == 0)
                    return "";

                return ((AssemblyProductAttribute)attributes[0]).Product;
            }
        }

        /// <summary>
        /// Product copyright info
        /// </summary>
        public static string AssemblyCopyright
        {
            get
            {
                object[] attributes = CurrentAssembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
                if (attributes.Length == 0)
                    return "";

                return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
            }
        }

        /// <summary>
        /// Product company
        /// </summary>
        public static string AssemblyCompany
        {
            get
            {
                object[] attributes = CurrentAssembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
                if (attributes.Length == 0)
                    return "";

                return ((AssemblyCompanyAttribute)attributes[0]).Company;
            }
        }

        /// <summary>
        /// Email of author of product
        /// </summary>
        public static string AuthorEmail
        {
            get { return authorEmail; }
        }
        #endregion
    }
}
